Skip to content

fix(core): [Session based Traces for Mobile 1] Keep spanless baggage mutable#5384

Draft
adinauer wants to merge 2 commits intofeat/session-based-traces-mobilefrom
fix/session-based-traces-mobile-baggage-freeze
Draft

fix(core): [Session based Traces for Mobile 1] Keep spanless baggage mutable#5384
adinauer wants to merge 2 commits intofeat/session-based-traces-mobilefrom
fix/session-based-traces-mobile-baggage-freeze

Conversation

@adinauer
Copy link
Copy Markdown
Member

@adinauer adinauer commented May 7, 2026

PR Stack (Session based Traces for Mobile)


📜 Description

Keeps local scope baggage mutable after spanless trace propagation. TracingUtils.maybeUpdateBaggage now freezes baggage only when it was marked as shouldFreeze, which protects incoming Sentry DSC without finalizing local propagation baggage.

Adds regression coverage for the spanless-before-transaction sequence to ensure a later transaction can still write sentry-transaction, sentry-sampled, and sentry-sample_rate into outgoing DSC.

💡 Motivation and Context

For session-based traces on mobile, an outgoing request can happen before an Activity or navigation transaction starts. Previously, that spanless request froze local scope baggage, and a later transaction could inherit frozen baggage and miss transaction-specific DSC fields.

This keeps incoming/fixed DSC protected while allowing local session trace baggage to be completed by the eventual transaction.

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • ./gradlew :sentry:test --tests io.sentry.util.TracingUtilsTest

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Continue the Session based Traces for Mobile stack.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

Only freeze scope baggage during spanless propagation when it carries incoming Sentry DSC values that should be protected. This keeps local propagation baggage writable for a later transaction so transaction-specific DSC can be emitted.

Co-Authored-By: Claude <[email protected]>
@adinauer
Copy link
Copy Markdown
Member Author

adinauer commented May 7, 2026

@sentry review

@adinauer
Copy link
Copy Markdown
Member Author

adinauer commented May 7, 2026

cursor review

@sentry
Copy link
Copy Markdown

sentry Bot commented May 7, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.41.0 (1) release

⚙️ sentry-android Build Distribution Settings

Comment thread CHANGELOG.md

### Fixes

- Fix transaction-specific dynamic sampling context fields missing after earlier spanless outgoing requests ([#5384](https://github.com/getsentry/sentry-java/pull/5384))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 🚫 The changelog entry seems to be part of an already released section ## 8.41.0.
    Consider moving the entry to the ## Unreleased section, please.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7cce069. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 316.22 ms 350.00 ms 33.78 ms
Size 0 B 0 B 0 B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant